<?php

namespace logInController;

require_once '\view\LogInPage.php';
require_once '\view\Bootstraphtml.php';
require_once '\model\LogInModel.php';

class LogInController{
	
	private $model;
	private $viewlogInPage;
	private $viewboothtml;
	private $LoggedInStatus;
		
	public function __construct(){
		$this->model = new \logInModel\LogInModel();
		$this->viewlogInPage = new \logInPage\LogInPage();
		$this->viewboothtml = new \bootstraphtml\Bootstraphtml();
	}		
		
	public function control(){
		if($this->viewlogInPage->logInButton() == TRUE){
		$this->loginControlChecker();
		}
		if($this->LoggedInStatus == TRUE){
			$header = $this->viewlogInPage->loggedInHeader();
		}else{
			$header = $this->viewlogInPage->loggedOutHeader();
		}
		$page = $this->viewlogInPage->getPage(); 
		$html = $this->viewboothtml->getbootstraphtml($page, $header);
		return $html;
	}
	private function loginControlChecker(){
		$username = $this->viewlogInPage->getUsername();
		$password = $this->viewlogInPage->getPassword();
		$this->LoggedInStatus = $this->model->tryLogIn($username, $password);
	}
}
